﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOTestMain.Classes
{
    public class Node<E>
    {
        private E data;
        private Node<E> link;

        public Node(E data, Node<E> link)
        {
            this.data = data;
            this.link = link;
        }

        public Node<E> Link
        {
            get { return link; }
        }

        public E Data
        {
            get { return data; }
        }
    }

    public class Link
    {
        public static void main()
        {
            DateTime startTime;
            TimeSpan endTime;
            startTime = DateTime.Now;

            int T = 10;
            int[] a = RandomHelper.ArrayGenerator(T);

            for(int i=0;i<T;i++)
            {
                Console.WriteLine("{0}\t", a[i]);
            }

            Console.WriteLine("//======================");

            Node<int> start = new Node<int>(a[T-1],null);
            Node<int> head = start;
            Node<int> next = null;

            for (int i = T-2; i >= 0; i--)
            {
                next = new Node<int>(a[i], start);
                start = next;
            }

            next = start;
            while (next != null)
            {
                Console.WriteLine(next.Data);
                next = next.Link;
            }

            Console.WriteLine("//=====================");
            endTime = DateTime.Now.Subtract(startTime);
            Console.WriteLine(endTime);
        }
    }
}
